using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using MAPDavy.Entities;

namespace MAPDavy.Repository.Mapping
{
	public class RITColorCodeMap : EntityTypeConfiguration<RITColorCode>
	{
		public RITColorCodeMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			// Table & Column Mappings
			this.ToTable("RITColorCode");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.SubjectId).HasColumnName("SubjectId");
			this.Property(t => t.MapId).HasColumnName("MapId");
			this.Property(t => t.GradeId).HasColumnName("GradeId");
			this.Property(t => t.ColorCodeId).HasColumnName("ColorCodeId");
			this.Property(t => t.LimInferior).HasColumnName("LimInferior");
			this.Property(t => t.LimSuperior).HasColumnName("LimSuperior");

			// Relationships
			this.HasRequired(t => t.ColorCode)
				.WithMany(t => t.RITColorCodes)
				.HasForeignKey(d => d.ColorCodeId);
				
			this.HasRequired(t => t.Grade)
				.WithMany(t => t.RITColorCodes)
				.HasForeignKey(d => d.GradeId);
				
			this.HasRequired(t => t.MAP)
				.WithMany(t => t.RITColorCodes)
				.HasForeignKey(d => d.MapId);
				
			this.HasRequired(t => t.Subject)
				.WithMany(t => t.RITColorCodes)
				.HasForeignKey(d => d.SubjectId);
				
		}
	}
}

